package com.test.sort;

import java.util.Arrays;
import java.util.Random;

/**
 * 
 * @author chenj
   @desc 冒泡排序
 *
 */
public class SortData1 {
     public static int max_length = 20;
	
	public static Integer[]  initArrayData()  {
		Integer[] arr = new Integer[max_length];
		Random random = new Random();
		for (int i = 0; i< max_length; i++) {
			
			arr[i] = random.nextInt(100);
		}
		return arr;
	}
	
	/** 冒泡排序*/
	public static Integer[] _sort1() {
		Integer[] arr = initArrayData();
		int out, in, temp;
		for (out = max_length-1; out > 0; out--) {
			for (in =0; in < out; in ++) {
				if (arr[in] > arr[in+1]) {
					temp = arr[in];
					arr[in] = arr[in+1];
					arr[in+1]= temp;
				}
			}
		}
		return arr;
		
	}
	//public static 
	
	public static void main(String[] args) {
		System.out.println(Arrays.toString(_sort1()));
		
	}
}
